﻿Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        timersplash.Enabled = True
        myfilename1 = "j:/Seniors.csv"
        myfilename2 = "j:/StudentNames/Info." & mynewline & " .csv"
        'Sets size and position of elements
        panelsplashscreen.Size = New System.Drawing.Size(Me.Height * 1.6180339887, Me.Height - 180)
        panelsplashscreen.Left = (Me.Width - panelsplashscreen.Width) * 0.5
        panelsplashscreen.Top = (Me.Height - panelsplashscreen.Height) * 0.5

        lblsplashscree1.Left = (panelsplashscreen.Width - lblsplashscree1.Width) * 0.5
        lblsplashscree1.Top = panelsplashscreen.Height * 0.55

        lblsplashscreen2.Left = (panelsplashscreen.Width * 0.25) - (lblsplashscreen2.Width) + 120
        lblsplashscreen2.Top = panelsplashscreen.Height * 0.33

        lblsplashscreen3.Left = (panelsplashscreen.Width * 0.75) - 120
        lblsplashscreen3.Top = panelsplashscreen.Height * 0.33

        lblsplashscreen4.Left = (panelsplashscreen.Width * 0.25) - (lblsplashscreen4.Width) + 120
        lblsplashscreen4.Top = panelsplashscreen.Height * 0.8

        lblsplashscreen5.Left = (panelsplashscreen.Width * 0.75) - 120
        lblsplashscreen5.Top = panelsplashscreen.Height * 0.8

        pmain.Size = New System.Drawing.Size(Me.Height * 1.6180339887, Me.Height - 180)
        pmain.Left = (Me.Width - panelsplashscreen.Width) * 0.5
        pmain.Top = (Me.Height - panelsplashscreen.Height) * 0.5

    End Sub

    Dim splashscreencounter As Integer
    Private Sub timersplash_Tick(sender As Object, e As EventArgs) Handles timersplash.Tick
        splashscreencounter = splashscreencounter + 1
        If splashscreencounter = 3 Then
            panelsplashscreen.Visible = False
        End If
    End Sub

    
    Private Sub bgo_Click(sender As Object, e As EventArgs) Handles bgo.Click
        'Finds student in file, and adds their data
        myCSVreader = My.Computer.FileSystem.OpenTextFileReader(myfilename1)
        While Not myCSVreader.EndOfStream
            mydata = myCSVreader.ReadLine().Split(",")
            mynewline = mydata(1) & " " & mydata(0)
            myIDnumber = mydata(3)

            If tbsearch.Text = mynewline Or myIDnumber.ToString Then

                'Creates student file
                myCSVreader = My.Computer.FileSystem.OpenTextFileReader(myfilename2)
                If myCSVreader IsNot Nothing Then
                    myCSVwriter = My.Computer.FileSystem.OpenTextFileWriter(myfilename2, True)
                    mynewline = ""
                    myCSVwriter.WriteLine(mynewline)
                    myCSVwriter.Close()

                End If
            End If
        End While

    End Sub
End Class
